<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理员首页 - 名片维护系统</title>
    <!-- <link rel="stylesheet" th:href="@{/css/styles.css}"> -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
    <style>
        /* Reset and Base Styles */
        :root {
            --primary-color: #3498db; /* Bright Blue */
            --primary-hover-color: #2980b9;
            --sidebar-bg: #2c3e50; /* Dark Blue/Grey */
            --sidebar-text-color: #ecf0f1;
            --sidebar-active-link-bg: #34495e;
            --sidebar-active-link-border: var(--primary-color);
            --content-bg: #f4f6f9; /* Very Light Grey */
            --text-color: #333;
            --text-muted-color: #777;
            --card-bg: #ffffff;
            --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
            --border-color: #e0e0e0;
            --success-color: #2ecc71;
            --error-color: #e74c3c;
            --font-family: 'Roboto', 'Helvetica Neue', Arial, sans-serif;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: var(--font-family);
            background-color: var(--content-bg);
            color: var(--text-color);
            line-height: 1.6;
            display: flex;
        }

        a {
            text-decoration: none;
            color: var(--primary-color);
        }

        a:hover {
            color: var(--primary-hover-color);
        }

        /* Admin Container */
        .admin-container {
            display: flex;
            width: 100%;
            min-height: 100vh;
        }

        /* Sidebar */
        .sidebar {
            width: 260px;
            background-color: var(--sidebar-bg);
            color: var(--sidebar-text-color);
            padding: 20px 0;
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
        }

        .sidebar-title {
            font-size: 1.5em;
            font-weight: 600;
            text-align: center;
            padding: 0 20px 20px 20px;
            margin-bottom: 20px;
            border-bottom: 1px solid rgba(236, 240, 241, 0.1);
            color: var(--sidebar-text-color);
        }

        .menu-list {
            list-style-type: none;
        }

        .menu-item .menu-link {
            display: block;
            padding: 15px 25px;
            color: var(--sidebar-text-color);
            font-size: 1em;
            transition: background-color 0.3s ease, color 0.3s ease, border-left 0.3s ease;
            border-left: 3px solid transparent;
            text-decoration: none; /* 添加这行去除下划线 */
        }

        .menu-item .menu-link .fa {
            margin-right: 10px;
            width: 20px; /* Align icons */
            text-align: center;
        }

        .menu-item .menu-link:hover {
            background-color: var(--sidebar-active-link-bg);
            border-left-color: var(--primary-hover-color);
            color: #fff;
        }

        .menu-item .menu-link.active {
            background-color: var(--sidebar-active-link-bg);
            border-left-color: var(--sidebar-active-link-border);
            font-weight: 600;
            color: #fff;
        }

        /* Main Content */
        .main-content {
            flex-grow: 1;
            background-color: var(--content-bg);
            padding: 0;
            display: flex;
            flex-direction: column;
        }

        /* Header */
        .header {
            background-color: var(--card-bg);
            padding: 15px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            border-bottom: 1px solid var(--border-color);
        }

        .header-title {
            font-size: 1.8em;
            font-weight: 600;
            color: var(--text-color);
        }

        .logout-button {
            background-color: var(--primary-color);
            color: white;
            padding: 8px 15px;
            border-radius: 5px;
            font-size: 0.9em;
            transition: background-color 0.3s ease;
            border: none;
            cursor: pointer;
        }

        .logout-button:hover {
            background-color: var(--primary-hover-color);
            color: white;
        }

        .logout-button .fa {
            margin-right: 5px;
        }

        /* Dashboard Specific Styles */
        .dashboard {
            padding: 30px;
            flex-grow: 1;
        }

        .dashboard-section-title { /* Replaces h3 for better control */
            font-size: 1.5em;
            font-weight: 600;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid var(--border-color);
            color: var(--text-color);
        }

        .dashboard-cards {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 25px;
            margin-bottom: 30px;
        }

        .dashboard-card {
            background-color: var(--card-bg);
            border-radius: 8px;
            padding: 25px;
            box-shadow: var(--card-shadow);
            display: flex;
            align-items: center;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
        }

        .dashboard-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 6px 15px rgba(0,0,0,0.08);
        }

        .card-icon {
            font-size: 2.5em;
            color: var(--primary-color);
            margin-right: 20px;
            padding: 15px;
            background-color: rgba(52, 152, 219, 0.1); /* Light primary color background */
            border-radius: 50%;
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .card-info .card-title {
            font-size: 1em;
            color: var(--text-muted-color);
            margin-bottom: 5px;
            font-weight: 500;
        }

        .card-info .card-value {
            font-size: 2em;
            font-weight: 700;
            color: var(--text-color);
        }

        /* Table Styles */
        .table-container {
            background-color: var(--card-bg);
            border-radius: 8px;
            box-shadow: var(--card-shadow);
            overflow-x: auto; /* For responsive tables */
            padding: 20px;
        }

        .table {
            width: 100%;
            border-collapse: collapse;
        }

        .table th,
        .table td {
            padding: 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
            font-size: 0.95em;
        }

        .table th {
            background-color: #f8f9fa; /* Slightly different from content-bg for emphasis */
            font-weight: 600;
            color: var(--text-muted-color);
            text-transform: uppercase;
            font-size: 0.85em;
            letter-spacing: 0.5px;
        }

        .table tbody tr:hover {
            background-color: #f1f3f5;
        }

        .table tbody tr:last-child td {
            border-bottom: none;
        }

        .table td .status-locked {
            color: var(--error-color);
            font-weight: 500;
        }

        .table td .status-normal {
            color: var(--success-color);
            font-weight: 500;
        }

        .view-all-link {
            display: inline-block;
            margin-top: 20px;
            font-weight: 500;
            color: var(--primary-color);
            transition: color 0.3s ease;
        }
        .view-all-link:hover {
            color: var(--primary-hover-color);
        }
        .view-all-link .fa {
            margin-left: 5px;
        }

    </style>
</head>
<body>
    <div class="admin-container">
        <!-- 侧边栏 -->
        <div class="sidebar">
            <h2 class="sidebar-title">名片维护系统</h2>
            <ul class="menu-list">
                <li class="menu-item">
                    <a class="menu-link active" href="/admin/index"><i class="fa fa-home"></i>首页</a>
                </li>
                <li class="menu-item">
                    <a class="menu-link" href="/admin/user-management"><i class="fa fa-users"></i>用户管理</a>
                </li>
                <li class="menu-item">
                    <a class="menu-link" href="/admin/usergroup"><i class="fa fa-user-circle"></i>用户组管理</a>
                </li>
                <li class="menu-item">
                    <a class="menu-link" href="/admin/change-password"><i class="fa fa-key"></i>修改密码</a>
                </li>
            </ul>
        </div>

        <!-- 主要内容 -->
        <div class="main-content">
            <div class="header">
                <h2 class="header-title">管理员首页</h2>
                <a class="logout-button" href="/admin/logout"><i class="fa fa-sign-out"></i>退出登录</a>
            </div>

            <div class="dashboard">
                <div class="dashboard-section-title">系统概览</div>
                <div class="dashboard-cards">
                    <div class="dashboard-card">
                        <div class="card-icon"><i class="fa fa-users"></i></div>
                        <div class="card-info">
                        <div class="card-title">用户总数</div>
                        <div class="card-value" th:text="${#lists.size(userList)}">0</div>
                        </div>
                    </div>
                    <!-- Add more cards here if needed, e.g.:
                    <div class="dashboard-card">
                        <div class="card-icon"><i class="fa fa-id-card"></i></div>
                        <div class="card-info">
                            <div class="card-title">名片总数</div>
                            <div class="card-value">125</div>
                        </div>
                    </div>
                    <div class="dashboard-card">
                        <div class="card-icon"><i class="fa fa-eye"></i></div>
                        <div class="card-info">
                            <div class="card-title">今日访问</div>
                            <div class="card-value">842</div>
                        </div>
                    </div>
                    -->
                </div>

                <div class="dashboard-section-title">最新用户 (前5条)</div>
                <div class="table-container">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>用户名</th>
                                <th>邮箱</th>
                                <th>角色</th>
                                <th>创建时间</th>
                                <th>状态</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr th:each="user, stat : ${userList}" th:if="${stat.index < 5}">
                                <td th:text="${user.id}">1</td>
                                <td th:text="${user.username}">用户名</td>
                                <td th:text="${user.email}">邮箱</td>
                                <td th:text="${user.role}">角色</td>
                                <td th:text="${user.createTime != null ? #dates.format(user.createTime, 'yyyy-MM-dd HH:mm:ss') : '-'}">创建时间</td>
                                <td>
                                   <span th:if="${user.accountLocked}" class="status-locked">已锁定</span>
                                   <span th:unless="${user.accountLocked}" class="status-normal">正常</span>
                                </td>
                            </tr>
                            <tr th:if="${#lists.isEmpty(userList) or #lists.size(userList) == 0}">
                                <td colspan="6" style="text-align: center; padding: 20px; color: var(--text-muted-color);">暂无用户数据</td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <div style="margin-top: 20px;">
                    <a href="/admin/user-management" class="view-all-link">查看所有用户 <i class="fa fa-arrow-right"></i></a>
                </div>
            </div>
        </div>
    </div>

    <!-- Removed old style block -->
</body>
</html>
